package Text_87;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class Code {

	public static void main(String[] args) throws IOException {
		  //发送数据
        //创建对象
        DatagramSocket dgs = new DatagramSocket();
        //数据内容
        String str = "Hello !";
        //将数据转换为字节数组
        byte[] bytes = str.getBytes();
//        for (byte aByte : bytes) {
//            System.out.println(aByte);
//        }
        //对方IP地址
        InetAddress byName = InetAddress.getByName("127.0.0.1");
        //端口号
        int port = 10086;
        //数据包装
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length, byName, port);
        //发送
        dgs.send(dp);
        //释放资源
        dgs.close();

	}

}
